﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer
{
    public class SMSFacade
    {
        DepartmentFacade depFac=new DepartmentFacade();
        EmployeeFacade empFac=new EmployeeFacade();
        CollectionPointFacade colFac=new CollectionPointFacade();
        Employee emp;
        Department dep;

        public SMSFacade()
        {
            InventorySoreDataContext context = new InventorySoreDataContext();
        }

        public string getEmpPhNo(string empID)
        {
            emp = empFac.FindEmployeeByID(empID);
            return emp.MobileNumber;
        }

        public void smsToClerk(string empID,string itemCode)
        {
            dep = depFac.FindDepartmentByDepartmentID(depFac.getDepartmentCode(empID));
            string sendTo = getEmpPhNo(dep.ClerkID);
            string smsText = "Item code " + itemCode + " in the inventory is under reorder level";
            SMSGateway.SMSGateway.SendSMS(sendTo, smsText);
        }

        public void smsToEmployee(string empName,string formID,string status)
        {
            emp = empFac.FindEmployeeByName(empName);
            string empID = emp.EmployeeID;
            string smsText = "Your stationary requisition form ID: " + formID + " has been " + status + ".";
            string sendTo = getEmpPhNo(empID);
            SMSGateway.SMSGateway.SendSMS(sendTo, smsText);
        }

        public void smsToRepresentative(string depCode)
        {
            dep = depFac.FindDepartmentByDepartmentID(depCode);
            string collPt = colFac.GetLocation(dep.CollectionPointID);
            TimeSpan temp = colFac.GetTime(dep.CollectionPointID);
            string time = temp.ToString();
            string smsText = "Please be reminded that you have to come on Monday at " + collPt + " at " + time + " to collect the stationery disbursement. Thank You - Stationery Store";
            string sendTo = getEmpPhNo(dep.RepresentativeID);
            SMSGateway.SMSGateway.SendSMS(sendTo, smsText);
        }
    }
}
